// Copyright (c) 2009 Mike Haight, Andy Kipp
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.

#pragma once

#include "stdafx.h"
#include "Object.h"
#include "Logger.h"
#include "Size.h"
#include "Actor.h"
#include "Layer.h"
#include "Xml.h"

namespace HandBanana { namespace Game
{
    /// <summary>
    /// 
    /// </summary>
    class Scene : public HandBanana::Core::Object, public HandBanana::Utilities::Xml::IXmlSerializable
    {
    // Constructors
    public:
        /// <summary>
        /// Create a new instance of the Scene class
        /// </summary>
        Scene(void);


    // Destructors
    public:
        /// <summary>
        /// Destory instance of the Scene class
        /// </summary>
        ~Scene(void);


    // Public Methods
    public:
        /// <summary>
        /// Gets the name of the Scene
        /// <summary>
        std::wstring Name(void) const;

        /// <summary>
        /// Gets the Size of the Scene
        /// </summary>
        HandBanana::Core::Size Size(void) const;

        /// <summary>
        /// Get an Actor in the Scene
        /// </summary>
        Actor* GetActor(const std::wstring& argName) const;

        /// <summary>
        /// Add an Actor to the Scene
        /// </summary>
        void AddActor(const std::wstring& argName, Actor* argActor);

        /// <summary>
        /// Remove an Actor from the Scene
        /// </summary>
        void RemoveActor(const std::wstring& argName);

        /// <summary>
        /// Get a Layer in the Scene
        /// </summary>
        Layer* GetLayer(const std::wstring& argName) const;

        /// <summary>
        /// Add a Layer to the Scene
        /// </summary>
        void AddLayer(const std::wstring& argName, Layer* argLayer);

        /// <summary>
        /// Remove a Layer from the Scene
        /// </summary>
        void RemoveLayer(const std::wstring& argName);

        ///// <summary>
        ///// Get a List of WorldObjects in the given Rectangle
        ///// </summary>
        //virtual List<WorldObject^>^ GetObjects(Coordinates::Rectangle argRectangle);


    // IXmlSerilisable Methods
    public:
        /// <summary>
        /// Implements the IXmlSerializable::ReadXml method
        /// </summary>
        virtual void ReadXml(const HandBanana::Utilities::Xml::XmlReader& argReader);

        /// <summary>
        /// Implements the IXmlSerializable::WriteXml method
        /// </summary>
        virtual void WriteXml(const HandBanana::Utilities::Xml::XmlWriter& argWriter);


    // Static Methods
    public:
        /// <summary>
        /// 
        /// </summary>
        static Scene* Load(const std::wstring& argFileName);


    // Private Data Members
    private:
        std::wstring                                mName;
        HandBanana::Core::Size                      mSize;
        std::map<std::wstring, Actor*>              mActors;
        std::map<std::wstring, Layer*>              mLayers;


    };
} }